﻿(define (string=? string1 string2)
  (let ((end (string-length string1)))
    (and (= end (string-length string2))
	 (let loop ((i 0))
	   (or (= i end)
	       (and (char=? (string-ref string1 i) (string-ref string2 i))
		    (loop (+ i 1))))))))

(define (substring->list string start end)
  (if (= start end)
      '()
      (let loop ((index (- end 1)) (chars '()))
		(if (= start index)
			(cons (string-ref string index) chars)
			(loop (- index 1) (cons (string-ref string index) chars))))))

(define (string->list string)
  (substring->list string 0 (string-length string)))

(define (list->string chars)
  (let ((result (make-string (length chars))))
    (let loop ((chars chars) (index 0))
      (if (pair? chars)
	  (begin
	    (string-set! result index (car chars))
	    (loop (cdr chars) (+ index 1)))
	  result))))

